package org.jeecg.common.api.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecg.common.constant.ErrorMsg;

import java.io.Serializable;

/**
 *   接口返回数据格式 - 市停车平台
 */
@Data
@ApiModel(value="接口返回对象", description="接口返回对象")
public class ShParkingResult<T> implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 返回处理消息
	 */
	@ApiModelProperty(value = "返回处理消息")
	private String message = "成功";

	/**
	 * 返回代码
	 */
	@ApiModelProperty(value = "返回代码")
	private Integer status;

	@ApiModelProperty(value = "返回数据对象")
	private T data;

	public ShParkingResult() {
	}

	public static <T> ShParkingResult<T> error(String msg) {
		return error(1, msg);
	}
	
	public static <T> ShParkingResult<T> error(int status, String msg) {
		ShParkingResult<T> r = new ShParkingResult<>();
		r.setStatus(status);
		r.setMessage(msg);
		return r;
	}

	public static <T> ShParkingResult<T> ok(int status, String msg) {
		ShParkingResult<T> r = new ShParkingResult<>();
		r.setStatus(status);
		r.setMessage(msg);
		return r;
	}
	
	public static <T> ShParkingResult<T> ok() {
		ShParkingResult<T> r = new ShParkingResult<>();
		r.setStatus(0);
		r.setMessage("成功");
		return r;
	}
	
	public static <T> ShParkingResult<T> ok(String msg) {
		ShParkingResult<T> r = new ShParkingResult<>();
		r.setStatus(0);
		r.setMessage(msg);
		return r;
	}
	
	public static <T> ShParkingResult<T> ok(T data) {
		ShParkingResult<T> r = new ShParkingResult<>();
		r.setStatus(0);
		r.setData(data);
		return r;
	}

	public static <T> ShParkingResult<T> ok(Integer status, String message) {
		ShParkingResult<T> r = new ShParkingResult<>();
		r.setMessage(message);
		r.setStatus(status);
		return r;
	}

	public static <T> ShParkingResult<T> error(ErrorMsg errorMsg) {
		return error(errorMsg.getCode(), errorMsg.getMsg());
	}


}